# 使用本地基础镜像
FROM openeuler_cuda_python

# Create a user that can be used to run triton as
# non-root. Make sure that this user to given ID 1000. All server
# artifacts copied below are assign to this user.
ENV TRITON_SERVER_USER=triton-server
RUN userdel tensorrt-server > /dev/null 2>&1 || true \
      && if ! id -u $TRITON_SERVER_USER > /dev/null 2>&1 ; then \
          useradd $TRITON_SERVER_USER; \
        fi \
      && [ `id -u $TRITON_SERVER_USER` -eq 1000 ] \
      && [ `id -g $TRITON_SERVER_USER` -eq 1000 ]


# 添加仓库并更新包管理器缓存
RUN dnf config-manager --add-repo https://repo.openeuler.openatom.cn/openEuler-24.03-LTS/update/$(uname -m)/ \
    && dnf install -y gcc \
    && dnf clean all \
    && rm -rf /etc/yum.repos.d/repo* \
    && rm -rf /tmp/*

# 将本地的 tritonserver 文件夹复制到镜像内的 /opt 目录下
WORKDIR /opt
COPY --chown=1000:1000 build/tritonserver tritonserver
ENV PATH=/opt/tritonserver/bin:$PATH
WORKDIR /opt/tritonserver
# 如果需要在构建后运行某些命令，可以在这里添加 CMD 或 ENTRYPOINT 指令